package com.black.cat.jvm.instructions.base;

import com.black.cat.jvm.rtda.Frame;

/**
 * @Author blackcat
 * @create 2021/8/13 14:15
 * @version: 1.0
 * @description:指令接口定义
 */
public interface Instruction {

    //从字节码中提取操作数
    void fetchOperands(BytecodeReader reader);
    //执行指令逻辑
    void execute(Frame frame);

    static void branch(Frame frame, int offset) {
        int pc = frame.thread().pc();
        int nextPC = pc + offset;
        frame.setNextPC(nextPC);
    }

}
